package com.jade.bss.admin.permission;

import java.util.List;

import com.jade.bss.admin.AdminException;

/**
 * PermissionEntry 数据访问接口。
 *
 * @author sky
 * @version 1.0 13-4-18 上午9:30
 */
public interface PermissionDao
{
    /**
     * Returns the permission entry with the specified ID.
     *
     * @param id permission id
     * @return the permission entry with the specified ID.
     */
    public PermissionEntry getPermission(int id);

    /**
     * Returns the permission entry with the specified name.
     *
     * @param name permission name
     * @return the permission entry with the specified name.
     */
    public PermissionEntry getPermission(String name);

    /**
     * Update the permission entry.
     *
     * @param permission permission entry.
     */
    public void updatePermission(PermissionEntry permission)
            throws AdminException;

    /**
     * Returns the list of all permission entries.
     *
     * @return the list of all permission entries.
     */
    public List<PermissionEntry> listPermission();

    /**
     * Add a new permission entry.
     *
     * @param permission the permission entry to be added.
     * @return the new permission entry's id
     * @throws AdminException if the operation can't be completed because some reasons, such as database error.
     */
    public int addPermission(PermissionEntry permission)
            throws AdminException;

    /**
     * Removes the permission entry with the specified ID.
     *
     * @param permissionId the ID of permission entry.
     * @throws AdminException if the operation can't be completed because some reasons, such as database error.
     */
    public void removePermission(int permissionId)
            throws AdminException;

    /**
     * Return the permission group with the specified ID.
     *
     * @param id permission group's ID
     * @return permission group
     */
    public PermissionGroup getGroup(int id);

    /**
     * Return the list of all permission groups.
     *
     * @return the list of all permission groups
     */
    public List<PermissionGroup> listGroup();

    /**
     * Adds a permission group.
     *
     * @param group permission group
     * @return group's ID
     * @throws AdminException name conflicted; unexpected error
     */
    public int addGroup(PermissionGroup group)
            throws AdminException;

    /**
     * Removes a permission group.
     *
     * @param groupId permission group's ID
     * @throws AdminException unexpected error
     */
    public void removeGroup(int groupId)
            throws AdminException;

}
